const Koa = require('koa');
const app = new Koa();
const bodyParser = require('koa-bodyparser');
const Router = require('koa-router');
const router = new Router();

router.get('/', (ctx, next) => {
    ctx.body = `
        <h1>登录</h1>
        <form method="POST", action=""/>
            <p>用户名</p>
            <input name='userName' /><br/>
            <h1>密码</h1>
            <input name='password' type="password" /><br/>
            <button type="submit">submit</button>
        </form>`;
});

router.post('/', (ctx, next) => {
    let postData = ctx.request.body;
    ctx.body = postData;
});

app.use(bodyParser())
    .use(router.routes())
    .use(router.allowedMethods);

app.listen(3000);
